<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
    <th:block th:include="include :: header('培训历史')"/>
    <th:block th:include="include :: layout-latest-css"/>
    <th:block th:include="include :: ztree-css"/>
    <th:block th:include="include :: select2-css"/>
</head>
<body class="gray-bg">
<div class="ui-layout-center">
    <div class="container-div">
        <div class="row">
            <div class="col-sm-12 search-collapse">
                <form id="user-form">
                    <div class="select-list">
                        <ul>
                            <li>
                                姓名：<input type="text" name="name"/>
                            </li>
                            <li>
                                工号：<input type="text" name="badge"/>
                            </li>
                            <li>
                                <a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i
                                        class="fa fa-search"></i>&nbsp;搜索</a>
                                <a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i
                                        class="fa fa-refresh"></i>&nbsp;重置</a>
                            </li>
                        </ul>
                    </div>
                </form>
            </div>

            <div class="btn-group-sm" id="toolbar" role="group">

            </div>

            <div class="col-sm-12 select-table table-striped">
                <table id="bootstrap-table"></table>
            </div>
        </div>
    </div>
</div>

<th:block th:include="include :: footer"/>
<th:block th:include="include :: layout-latest-js"/>
<th:block th:include="include :: ztree-js"/>

<script th:inline="javascript">
    var prefix = ctx + "trainManage";
    $(function () {
        var panehHidden = false;
        if ($(this).width() < 800) {
            panehHidden = true;
        }
        $('body').layout({initClosed: panehHidden, west__size: 350});
        queryData();
    });

    function queryData() {
        var columns = [];
        var checkbox = {checkbox: true};
        var id = {field: 'id', title: '序号'};
        var comp = {field: 'comp', title: '集团'};
        var center = {field: 'center', title: '所属中心'};
        var trainingProgram = {field: 'trainingProgram', title: '培训项目'};
        var trainingPurpose = {field: 'trainingPurpose', title: '培训目的'};
        var studentDescription = {field: 'studentDescription', title: '学员描述'};
        var studentLevel = {field: 'studentLevel', title: '学员层级'};
        var number = {
            title: '参加人数',
            align: "center",
            formatter: function (value, row, index) {
                var actions = [];
                actions.push('<a href="javascript:void(0)" onclick="getEmp(\'' + row.id + '\')">' + row.number + '</a>');
                return actions.join('');
            }
        };
        var professionalLine = {field: 'professionalLine', title: '所属专业线'};
        var implementationTime = {field: 'implementationTime', title: '实施时间'};
        var beginDate = {field: 'beginDate', title: '开始时间'};
        var endDate = {field: 'endDate', title: '结束时间'};
        var participationMode = {field: 'participationMode', title: '参加方式'};
        var professional = {field: 'professional', title: '专业类'};
        var classHour = {field: 'classHour', title: '课时(时)'};
        var totalClassHours = {field: 'totalClassHours', title: '总课时(时)'};
        var inside = {field: 'inside', title: '内部'};
        var instructorName = {field: 'instructorName', title: '讲师姓名'};
        var lecturer = {field: 'lecturer', title: '讲师所在部门/机构'};
        var diningAndVenue = {field: 'diningAndVenue', title: '餐饮及场地'};
        var teachers = {field: 'teachers', title: '师资'};
        var other = {field: 'other', title: '其它'};
        var total = {field: 'total', title: '合计'};
        var remark = {field: 'remark', title: '备注'};
        var operation = {
            title: '操作',
            align: "center",
            formatter: function (value, row, index) {
                var actions = [];
                actions.push('<a class="btn btn-info btn-xs" href="javascript:void(0)" onclick="upload(\'' + row.id + '\')"><i class="fa fa-upload"></i>查看培训材料</a>');
                return actions.join('');
            }
        };
        columns.push(checkbox, id, comp, center, trainingProgram, trainingPurpose, studentDescription, studentLevel);
        columns.push(number, professionalLine, implementationTime, beginDate, endDate, participationMode, professional, classHour);
        columns.push(totalClassHours, inside, instructorName, lecturer, diningAndVenue, teachers, other, total, remark, operation);

        var options = {
            code: "id",
            uniqueId: "id",
            url: prefix + "/findDataListHistory",
            createUrl: prefix + "/addTrain",
            updateUrl: prefix + "/edit/{id}",
            removeUrl: prefix + "/remove",
            detailUrl: prefix + "/detail/{id}",
            escape: true,
            showPageGo: true,
            rememberSelected: true,
            height: $(window).height() - 120,
            sortOrder: "desc",
            modalName: "培训管理",
            columns: columns
        };
        $.table.init(options);
    }

    function staffing(id) {
        $.operate.edit_currency("配置参加培训人员", '', id, "", prefix + "/staffing", "xiao");
    }

    function upload(id) {
        $.operate.edit_currency("上传培训材料", '', id, "", prefix + "/uploadHistory", "da");
    }

    function getEmp(id) {
        $.operate.edit_currency("参加培训人员列表", '', id, "", prefix + "/toEmpListHistory", "da");
    }

    function sealUp() {
        var trainId = "";
        var row = $("#bootstrap-table").bootstrapTable('getSelections');
        if (row.length != 1) {
            alert("请选择一条数据");
            return;
        }
        trainId = row[0].id;
        //先查询此培训有没有已经封存
        $.ajax({
            url: prefix + "/isSeal",
            data: {
                "trainId": trainId
            },
            type: "post",
            dataType: "json",
            success: function (data) {
                if(data.code == 1){
                    alert("数据已经封存!");
                }else{
                    alert("封存成功!");
                }
            },
        });
    }

</script>
</body>
</html>